﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.SheepMomWeaningCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 种母断奶管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepWeaningController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public SheepWeaningController(IMediator mediator)
        {
            _mediator = mediator;
        }


        /// <summary>
        /// 种母断奶添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> SheepWeaningAdd(SheepWeaningCreateCommand command)
        {
            return await _mediator.Send(command); 
        }


        /// <summary>
        /// 种母断奶列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Results<List<SheepMomWeaning>>> GetSheepWeaning([FromQuery] SheepWeaningSelectCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 种母断奶批量删除/逻辑删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<Results<int>> DeleteSheepWeaning(SheepWeaningDeleteCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 种母断奶单个数据
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Results<SheepMomWeaning>> SheepWeaningInfo([FromQuery] SheepWeaningFillCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 种母断奶修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdateSheepWeaning(SheepWeaningUpdateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 种母断奶审核状态
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdateSheepWeaningState(SheepWeaningAuditCommand command)
        {
            return await _mediator.Send(command);
        }

    }
}
